#include "XgSignalBase.h"
#include "XgExceptions.h"

XgSignalBase::XgSignalBase()
{
	_win32Event = CreateEvent(NULL, TRUE, FALSE, NULL);
	if(!_win32Event)
	{
		throw XG_CANT_CREATE_W32EVENT_EX;
	}
}

void XgSignalBase::set()
{
	if( !SetEvent(_win32Event) )
	{
		throw XG_CANT_SIGNAL_W32EVENT_EX;
	}
}

void XgSignalBase::reset()
{
	if( !ResetEvent(_win32Event) )
	{
		throw XG_CANT_RESET_W32EVENT_EX;
	}
}

void XgSignalBase::wait()
{
	if( ::WaitForSingleObject(_win32Event, INFINITE) == WAIT_FAILED )
	{
		throw XG_WAIT_W32EVENT_FAILED_EX;
	}
}